package com.unity3d.player;

import android.view.*;
import android.graphics.*;
import android.graphics.drawable.*;

public final class i implements View.OnLayoutChangeListener
{
    final View a;
    final int b;
    final int c;
    Bitmap d;
    Bitmap e;
    Drawable f;

    public i(final View a, final int b) {
        this.a = a;
        this.b = b;
        this.c = a.getResources().getIdentifier("unity_static_splash", "drawable", a.getContext().getPackageName());
        if (this.c != 0) {
            this.a.addOnLayoutChangeListener((View.OnLayoutChangeListener)this);
            this.a.forceLayout();
        }
    }

    public final void onLayoutChange(final View view, int n, int width, int height, int width2, int height2, int n2, final int n3, final int n4) {
        if (this.f == null) {
            this.f = view.getBackground();
        }
        if (this.d == null) {
            this.d = BitmapFactory.decodeResource(view.getResources(), this.c);
        }
        width2 = this.d.getWidth();
        height = this.d.getHeight();
        width = view.getWidth();
        height2 = view.getHeight();
        if (width != 0) {
            if (height2 == 0) {
                return;
            }
            final float n5 = width2 / (float)height;
            final float n6 = (float)width;
            final float n7 = (float)height2;
            if (n6 / n7 <= n5) {
                n = 1;
            }
            else {
                n = 0;
            }
            n2 = i$1.a[this.b - 1];
            Label_0232: {
                if (n2 != 1) {
                    if (n2 != 2 && n2 != 3) {
                        n = width2;
                        width = height;
                        break Label_0232;
                    }
                    if (this.b == i.a.c) {
                        height = 1;
                    }
                    else {
                        height = 0;
                    }
                    if ((height ^ n) != 0x0) {
                        height = (int)(n6 / n5);
                        n = width;
                        width = height;
                        break Label_0232;
                    }
                }
                else {
                    if (width < (n = width2)) {
                        height = (int)(n6 / n5);
                        n = width;
                    }
                    if (height2 >= (width = height)) {
                        break Label_0232;
                    }
                }
                n = (int)(n7 * n5);
                width = height2;
            }
            final Bitmap e = this.e;
            if (e != null && e.getWidth() == n && this.e.getHeight() == width) {
                return;
            }
            this.e = Bitmap.createScaledBitmap(this.d, n, width, true);
            final ColorDrawable colorDrawable = new ColorDrawable(-16777216);
            final BitmapDrawable bitmapDrawable = new BitmapDrawable(view.getResources(), this.e);
            bitmapDrawable.setGravity(17);
            view.setBackgroundDrawable((Drawable)new LayerDrawable(new Drawable[] { (Drawable)colorDrawable, (Drawable)bitmapDrawable }));
        }
    }

    enum a
    {
        public static final int a = 1;
        public static final int b = 2;
        public static final int c = 3;
        private static final /* synthetic */ int[] d;

        static {
            d = new int[] { i.a.a, i.a.b, i.a.c };
        }

        public static int[] a() {
            return i.a.d.clone();
        }
    }
}
